<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>气密性检测</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
	<style type="text/css">
		.layui-form-item {
			display: inline-block;
			width: 30%;
		}
		/* .layui-table-cell {
			overflow:visible;
		} */
		thead .layui-table-cell{
		   	height:auto;
		  	overflow:visible;
		  	text-overflow:inherit;
		 	white-space:normal;
		 	text-align: center;
		}
		#details form .layui-input {
			border-top:none;
			border-left:none;
			border-right:none;
			border-bottom:1px solid #AAA !important;
			background-color: rgb(242,242,242);
			border-radius:0;
		}
	</style>
</head>
<body>
<script type="text/html" id="gasList">
    {{d.LAY_TABLE_INDEX+1}} 次气密性检测
</script>
<div style="background-color: #0997F7">
	<h2 style="color:#FFF">工位：气密性检测工位</h2>
</div>
<div class="" style="margin:10px 0 0 15px;width: 98%">
	<div class="layui-inline">
		<label style="padding:9px 9px;float:left">产品条码：</label><input class="layui-input" id="gCode" style="width: 200px" placeholder="请扫描产品条码" lay-verify="">
	</div>
	<div class="layui-inline">
		<label style="padding:9px 9px;float:left">设备编号：</label><input class="layui-input" id="facilityNumber" style="width: 200px" placeholder="请填写设备编号" lay-verify="">
	</div>
	<button class="layui-btn layui-btn-blue layui-hide" style="margin: 0 0 0 10px" id="reload" data-type="reload"><i class="layui-icon layui-icon-search">  搜索</i></button>
    <input class="layui-btn layui-btn-blue" type="button" style="padding: 0 30px;float:right" onclick = "checkTodayLog()" value="查看今日工作记录">
    <input class="layui-btn layui-btn-blue" type="button" style="padding: 0 30px;float:right" onclick = "checkHistoryLog()" value="组件历史记录">
</div>
<div>
	<h2 style="text-align: center;color:#666">气密检测记录</h2>
	<table class="layui-hide" id="gas" lay-filter="gas"></table>
</div>
<script type="text/html" id="leakHuntingList">
    {{d.LAY_TABLE_INDEX+1}} 次检漏
</script>
<!-- 疑似不良品信息 及操作 -->
<div id="details" style="margin:10px 0 0 15px;background-color:rgb(242,242,242);border-top:#e6e6e6 1px solid">
    <div>
    <input class="layui-hide" readonly id="remark01"/>
    <input class="layui-hide" readonly id="remark02"/>
    <input class="layui-hide" readonly id="remark04"/>
    	<table class="layui-table">
    		<thead>
    			<tr>
    				<th colspan="4"><h2 style="text-align: center;">订单信息</h2></th>
    			</tr>
    		</thead>
    		<tbody>
    			<tr>
    				<td width="20%">产品名称</td>
    				<td><input class="layui-input" readonly id="ptName"/></td>
    				<td width="20%">产品规格</td>
    				<td><input class="layui-input" readonly id="ptStandard"/></td>
    			</tr>
    			<tr>
    				<td width="20%">报检单号</td>
    				<td><input class="layui-input" readonly id="piNumber"/></td>
    				<td width="20%">质检单号</td>
    				<td><input class="layui-input" readonly id="number"/></td>
    			</tr>
    			<tr>
    				<td width="20%">报检人</td>
    				<td><input class="layui-input" readonly id="piPerson"/></td>
    				<td width="20%">报检日期</td>
    				<td><input class="layui-input" readonly id="piDate"/></td>
    			</tr>
    		</tbody>
    	</table>
    	<table class="layui-table">
    		<thead>
    			<tr>
    				<th colspan="5"><h2 style="text-align: center;">气密性检测</h2></th>
    			</tr>
    		</thead>
    		<tbody>
    			<tr>
    				<td width="20%">出泡间隔时间（S）</td><!-- gIntervalTime -->
	    				<!-- <td>
	    					<select class="layui-select" id="">
				   				<option value="-1">---请选择---</option>
				   				<option value="">></option>
				   				<option value="">&#60</option>
				   				<option value="">=</option>
			   				</select>
						</td> -->
	    				<td>
	    					<select class="layui-select" id="gIntervalTime">
				   				<option value="-1">---请选择---</option>
				   				<option value="${zcGasCriterionEntity.oneTime }">1次间隔 ${zcGasCriterionEntity.oneTime } s</option>
				   				<option value="${zcGasCriterionEntity.threeTime }">3次间隔 ${zcGasCriterionEntity.threeTime } s</option>
				   				<option value="0">其他</option>
			   				</select>
						</td>
    				<td width="20%">气密性检测结果</td>
    				<td>
    					<!-- <select class="layui-select" id="gResult">
			   				<option value="合格">合格</option>
			   				<option value="降级">降级</option>
			   				<option value="异常处理">异常处理</option>
		   				</select>	 -->	
		   				<input class="layui-input" id="gResult" onclick="isPass()" readonly value="">		
	    			</td>
    			</tr>
    		</tbody>
    	</table>
    	<input style="color:red" class="layui-input" value="* 注：气密性选择1次120s或3次20s，则气密区合格；气密区非(合格)，则气密区异常处理"/>
    	<input id="testTime" hidden/>
    	<div class="layui-form-item" style="width:100%">
	   		<div class="" style="margin:10px 0 0 10px">
		  		<input class="layui-btn layui-btn-blue layui-hide" type="button" style="padding: 0 30px" onclick = "save()" id="firstBtn" value="立即提交">
		  		<input class="layui-btn layui-btn-blue layui-hide" type="button" style="padding: 0 30px" onclick = "second()" id="secondBtn" value="保存">
		  		<input class="layui-btn layui-btn-blue" type="button" style="padding: 0 30px" onclick = "gasOver()" id="thirdBtn" value="提交">
		  		<input class="layui-btn layui-btn-blue" type="button" style="padding: 0 30px" onclick = "over()" id="fourth" value="最终判定">
		  		<input class="layui-btn layui-btn-blue" type="button" style="padding: 0 30px" onclick = "logout()" value="注销">
			</div>
		</div>
    </div>
</div>
<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
<script type="text/javascript">
window.onload = function(){
	var oInput = document.getElementById("gCode");
	oInput.focus();
}
//判定是否合格
function isPass(){
	$.ajax({
   	 url:'${pageContext.request.contextPath }/criterion/selectGasCriterion.do'
			,type:'post'
			,dataType:'json'
			,success:function(data){
				//console.log(data.ryCountOne)
				var gIntervalTime = Number($("#gIntervalTime").val());
				if(gIntervalTime==-1){
					toastr.warning("请选择出泡间隔时间！");
				}else if(gIntervalTime==data.oneTime||gIntervalTime==data.threeTime){
					$("#gResult").val("合格")
				}else{
					$("#gResult").val("异常处理")
				}
				
			}
    })
	
	
}
//查看今日工作量
function checkTodayLog(){
	layer.open({
        type: 1 					//Page层类型
        ,area: ['95%', '600px']   //宽  高
        ,title: '今日气密性检测记录'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true			    //允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        /* ,content: $("#lookupTable2") */
        ,content: '<table class="layui-hide" id="todayLog" lay-filter="todayLog"></table>'
        ,success:function(){
            layui.use(['table'], function(){
                var table = layui.table;
                table.render({
                    elem: '#todayLog'
                    ,url:'${pageContext.request.contextPath }/gas/selectTodayLogList.do'
                    ,title: '今日气密性检测记录'
                    ,limits:[10,20,30]
                    ,cols: [[
                        {field:'', title:'序号', sort: true, type:'numbers', width: 60}
                        ,{field:'number', title:'质检单号'}
                        ,{field:'gCode', title:'产品条码'}
                        ,{field:'facilityNumber', title:'设备编号'}
                        ,{field:'gIntervalTime', title:'出泡间隔时间'}
                        ,{field:'gResult', title:'检测结果'}
                        ,{field:'testPerson', title:'检验人'}
                        ,{field:'testTime', title:'检验时间',width:200,templet :function (row){
                            	return date2String(row.testTime);
                        	}   
                        }
                    ]]
                    ,page: true
                });
            });
        }
	})
}
//查询组件历史检测记录
function checkHistoryLog(){
	var code = $("#gCode").val();
	if(code==""){
		toastr.warning("请先扫描条形码！");
		setTimeout(function(){  //使用  setTimeout（）方法设定定时500毫秒
			window.location.reload();  
		},1000);
	}else{
		layer.open({
	        type: 1 					//Page层类型
	        ,area: ['95%', '600px']   //宽  高
	        ,title: '组件历史检测记录'
	        ,shade: 0.6 				//遮罩透明度
	        ,maxmin: true			    //允许全屏最小化
	        ,anim: 1 					//0-6的动画形式，-1不开启
	        /* ,content: $("#lookupTable2") */
	        ,content: '<table class="layui-hide" id="historyLog" lay-filter="historyLog"></table>'
	        ,success:function(){
	            layui.use(['table'], function(){
	                var table = layui.table;
	                table.render({
	                    elem: '#historyLog'
	                    ,url:'${pageContext.request.contextPath }/gas/selectHistoryLogList.do?code='+code
	                    ,title: '组件历史检测记录'
	                    ,limits:[10,20,30]
	                    ,cols: [[
	                        {field:'', title:'序号', sort: true, type:'numbers', width: 60}
	                        ,{field:'piNumber', title:'报检单号'}
	                        ,{field:'piPerson', title:'报检人'}
	                        ,{field:'piDate', title:'报检日期',width:200,templet :function (row){
	                        		return date2String(row.piDate);
	                    		}   
	                        }
	                        ,{field:'number', title:'质检单号'}
	                        ,{field:'ptName', title:'组件名称'}
	                        ,{field:'ptCode', title:'组件条码'}
	                        ,{field:'ptStandard', title:'组件规格'}
	                        ,{field:'remark01', title:'组件编号'}
	                        ,{field:'remark02', title:'排产单号'}
	                    ]]
	                    ,page: true
	                });
		             //监听行单击事件(子表)
		   	       	 table.on('row(historyLog)', function(obj){
		   	       		var ptId = obj.data.ptId;
		   	       		var productCode = obj.data.number;
		   	       		layer.open({
					        type: 1 					//Page层类型
					        ,area: ['95%', '750px']   //宽  高
					        ,title: '组件历史检测记录'
					        ,shade: 0.6 				//遮罩透明度
					        ,maxmin: true			    //允许全屏最小化
					        ,anim: 1 					//0-6的动画形式，-1不开启
					        /* ,content: $("#lookupTable2") */
					        ,content:   '<h2 style="text-align: center;color:#666">数点记录</h2>'+
					        			'<table class="layui-hide" id="numberedInfoLog" lay-filter="numberedInfoLog"></table>'+
					        			'<h2 style="text-align: center;color:#666">检漏记录</h2>'+
					        			'<table class="layui-hide" id="leakHuntingInfoLog" lay-filter="leakHuntingInfoLog"></table>'+
					        			'<h2 style="text-align: center;color:#666">组件评价记录</h2>'+
					        			'<table class="layui-hide" id="evaluateInfoLog" lay-filter="evaluateInfoLog"></table>'+
					        			'<h2 style="text-align: center;color:#666">气密性检测记录</h2>'+
					        			'<table class="layui-hide" id="gasInfoLog" lay-filter="gasInfoLog"></table>'
					        ,success:function(){
					            layui.use(['table'], function(){
					                var table = layui.table;
					                table.render({
					                    elem: '#numberedInfoLog'
					                    ,url:'${pageContext.request.contextPath }/leakHunting/selectNumberedInfoLogByCode.do?productCode='+productCode
					                    ,title: '数点记录'
					                    ,limits:[10,20,30]
					                   ,cols: [[
					             			  {field:'', title:'序号', sort: true, type:'numbers', width: 60}
					             			  ,{field:'rjNumA', title:'A面软胶堵漏数'}
					             		      ,{field:'rjNumB', title:'B面软胶堵漏数'}
					             		      ,{field:'yjNumA', title:'A面硬胶堵漏数'}
					             		      ,{field:'yjNumB', title:'B面硬胶堵漏数'}
					             		      ,{field:'ryjNumCountA', title:'A面软硬胶堵漏总数'}
					             		      ,{field:'ryjNumCountB', title:'B面软硬胶堵漏总数'}
					             		      ,{field:'bsNumA', title:'A面瘪丝数'}
					             		      ,{field:'bsNumB', title:'B面瘪丝数'}
					             		      ,{field:'wqysNumA', title:'A面弯曲压丝数'}
					             		      ,{field:'wqysNumB', title:'B面弯曲压丝数'}
					             		      ,{field:'isNormal', title:'端面是否正常'}
					             		      ,{field:'place', title:'异常位置'}
					             		      ,{field:'describe', title:'非正常描述'}
					             		      ,{field:'testPerson', title:'数点人'}
					             		      ,{field:'testTime',width:160, title:'数点日期',templet:function (row){
					                         		return date2String(row.testTime);
					                     		}
					             		      }
					             		    ]]
					          	    	,page: false
					                });
					                table.render({
					                    elem: '#leakHuntingInfoLog'
					                    ,url:'${pageContext.request.contextPath }/productTracing/selectLeakHuntingInfoLogByCode.do?productCode='+productCode
					                    ,title: '检漏记录'
					                    ,limits:[10,20,30]
						                ,cols: [[
						          			   {field:'', title:'序号', sort: true, type:'numbers', width: 60}
						          			  ,{field:'leakHunting',width:100, title: '检漏序列',templet:'#leakHuntingList',totalRowText: '合计'}
						          		      ,{field:'facilityNumber', title:'设备编号'}
						          		      ,{field:'aDlNumBig', title:'A面堵漏个数大'}
						          		      ,{field:'aDlNumSmall', title:'A面堵漏个数小'}
						          		      ,{field:'bDlNumBig', title:'B面堵漏个数大'}
						          		      ,{field:'bDlNumSmall', title:'B面堵漏个数小'}
						          		      ,{field:'aCount', title:'A面总数',totalRow: true}
						          		      ,{field:'bCount', title:'B面总数',totalRow: true}
						          		      ,{field:'isNormal', title:'检漏是否正常'}
						          		      ,{field:'lhResult', title:'检漏结果'}
						          		      ,{field:'describe', title:'非正常描述'}
						          		      ,{field:'testTime',width:160, title:'日期',templet:function (row){
						                      		return date2String(row.testTime);
						                  		}
						          		      }
						          		    ]]
					          	    	,page: true
					                });
					                table.render({
					            	    elem: '#evaluateInfoLog'
					            	    ,url:'${pageContext.request.contextPath }/productTracing/selectEvaluateInfoLogByCode.do?productCode='+productCode
					            	    ,title: '组件评价'
					            	    ,cols: [[
					            	      {field:'', title:'序号', sort: true, type:'numbers', width: 60}
					            	      ,{field:'yxsw', title:'运行水温℃'}
					            	      ,{field:'jsyl', title:'进水压力MPa'}
					            	      ,{field:'csyl', title:'产水压力MPa'}
					            	      ,{field:'nsyl', title:'浓水压力MPa'}
					            	      ,{field:'cstl', title:'产水通量T/h'}
					            	      ,{field:'nstl', title:'浓水通量T/h'}
					            	      ,{field:'yxTime', title:'运行时间h'}
					            	      ,{field:'evResult', title:'检测结果'}
					            	      ,{field:'testTime',width:160, title:'日期',templet:function (row){
					                      		return date2String(row.testTime);
					                  		}
					            	      }
					            	    ]]
					            	    ,page: false
					            	});
					                table.render({
					            	    elem: '#gasInfoLog'
					            	    ,url:'${pageContext.request.contextPath }/productTracing/selectGasInfoLogByCode.do?productCode='+productCode
					            	    ,title: '气密检测'
					            	    ,limits:[10,20,30]
					            	    ,cols: [[
					            	      {field:'', title:'序号', sort: true, type:'numbers', width: 60}
					            	      ,{field:'gas', width:150, title: '气密性检测序列',templet:'#gasList'}
					            	      ,{field:'gIntervalTime', title:'出泡间隔时间s'}
					            	      ,{field:'gResult', title:'检测结果'}
					            	      ,{field:'testTime',width:160, title:'日期',templet:function (row){
					                      		return date2String(row.testTime);
					                  		}
					            	      }
					            	    ]]
					            	    ,page: true
					            	});
					            });
					        }
						})
		   	       	});
	            });
	         
	        }
		})
	}
}
layui.use(['table','layer','upload','form'], function(){
	var table = layui.table;
	var layer = layui.layer,
    form = layui.form;
	
	var $ = layui.jquery, active = {
			reload:function () {
				var productCode = $("#gCode").val();
				table.reload('contenttable',{
					method:'get',
					where:{productCode:productCode}
					,page: {
						curr: 1 //重新从第 1 页开始
					}
				});
			}
		}
	$('.layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
	table.render({
	    elem: '#gas'
	    ,url:'${pageContext.request.contextPath }/productTracing/selectGasInfoByCode.do'
	    ,title: '气密性检测记录'
	    ,id :'contenttable'
	    ,limits:[10,20,30]
	    ,cols: [[
			   {field:'', title:'序号', sort: true, type:'numbers', width: 60}
			   ,{field:'gas',width:200, title: '气密行检测序列',templet:'#gasList'}
		      ,{field:'facilityNumber', title:'设备编号'}
		      ,{field:'gIntervalTime', title:'出泡间隔时间（s)'}
		      ,{field:'gResult', title:'气密性检测结果'}
		      ,{field:'testTime',width:200, title:'日期',templet:function (row){
            		return date2String(row.testTime);
        		}
		      }
		    ]]
	    ,done:function(data){
	    	var index = data.data.length-1;
	    	if(index>=0){
		    	if("已判定"==data.data[index].remark05){
		    		$("#secondBtn").attr("disabled",true);
		    		$("#secondBtn").css("background","#AAA");
		    		$("#thirdBtn").attr("disabled",true);
		    		$("#thirdBtn").css("background","#AAA");
		    	}else{
		    		$("#secondBtn").attr("disabled",false);
		    		$("#secondBtn").css("background","#009688");
		    		$("#thirdBtn").attr("disabled",false);
		    		$("#thirdBtn").css("background","#009688");
		    	}
	    	}
	    	if(data.count!='0'){
	    		$("#firstBtn").attr("disabled",true);
	    		$("#firstBtn").css("background","#AAA");
	    	}else{
				$("#firstBtn").attr("disabled",false);
    	    	$("#firstBtn").css("background","#009688");
			}
	    }
	    ,page: true
	});
});
//注销
function logout(){   
	  window.location.href="${pageContext.request.contextPath }/logout.do";
 }
//日期格式转换
function date2String(timestamp){
	var d = new Date(timestamp);
	var date = (d.getFullYear()) + "-" + 
       (d.getMonth() + 1<10?"0"+(d.getMonth() + 1):d.getMonth() + 1) + "-" +
       (d.getDate()<10?"0"+d.getDate():d.getDate()) + " " + 
       (d.getHours()<10?"0"+d.getHours():d.getHours()) + ":" + 
       (d.getMinutes()<10?"0"+d.getMinutes():d.getMinutes()) + ":" + 
       (d.getSeconds()<10?"0"+d.getSeconds():d.getSeconds());
       
       return date;
}
function keyDown(e){
    //IE内核浏览器  
     if (navigator.appName == 'Microsoft Internet Explorer'){  
           var keycode = event.keyCode;  
           var realkey = String.fromCharCode(event.keyCode);  
     }else {//非IE内核浏览器  
           var keycode = e.which;  
           var realkey = String.fromCharCode(e.which);  
     }  
   // console.log('按键码:' + keycode +  '字符: ' + realkey);  

   //监听Enter键  
   if(keycode==13){  
	    var d = new Date();
	    var date = (d.getFullYear()) + "-" + 
           (d.getMonth() + 1<10?"0"+(d.getMonth() + 1):d.getMonth() + 1) + "-" +
           (d.getDate()<10?"0"+d.getDate():d.getDate()) + " " + 
           (d.getHours()<10?"0"+d.getHours():d.getHours()) + ":" + 
           (d.getMinutes()<10?"0"+d.getMinutes():d.getMinutes()) + ":" + 
           (d.getSeconds()<10?"0"+d.getSeconds():d.getSeconds());
           $("#testTime").val(date);
         var code = $("#gCode").val();
         $.ajax({
        	 url:'${pageContext.request.contextPath }/numbered/selectProductTest.do'
 				,type:'post'
 				,data:{"code":code}
 				,dataType:'json'
 				,success:function(data){
 					if(data == 0){
 						toastr.warning("未找到订单！");
 						setTimeout(function(){  //使用  setTimeout（）方法设定定时500毫秒
 							window.location.reload();  
 						},500);
 					}else{
 						$.ajax({
 							url:'${pageContext.request.contextPath }/productTracing/selectEvaluateInfoByCode.do'
							,type:'post'
			 				,data:{"productCode":code}
			 				,dataType:'json'
			 				,success:function(data1){
			 					if(data1.count<=0){
			 						toastr.warning("请先进行组件评价操作！");
			 						$("#secondBtn").attr("disabled",true);
			 	     	    		$("#secondBtn").css("background","#AAA");
			 						$("#thirdBtn").attr("disabled",true);
			 	     	    		$("#thirdBtn").css("background","#AAA");
			 					}else{
			 						$("#secondBtn").attr("disabled",false);
			 						$("#secondBtn").css("background","#009688");
			 						$("#thirdBtn").attr("disabled",false);
			 						$("#thirdBtn").css("background","#009688");
			 					}
			 				}
 						})
 						$("#reload").click();
 						$("#ptName").val(data.ptName);
 	 					$("#ptStandard").val(data.ptStandard);
 	 					$("#piNumber").val(data.piNumber);
 	 					$("#number").val(data.number);
 	 					$("#piPerson").val(data.piPerson);
 	 					$("#piDate").val(date2String(data.piDate));
 	 					$("#remark01").val(data.remark01);
 	 					$("#remark02").val(data.remark02);
 	 					$("#remark04").val(data.remark04);
 					}
 				}
         })
   }  
   
}  
//按键事件
document.onkeydown=keyDown;	
//保存
function save(){
	$("#firstBtn").attr("disabled",true);
	var gCode = $("#gCode").val();
	var gResult = $("#gResult").val();
	if(gCode==""){
		toastr.warning("请先扫描条形码！");
		$("#firstBtn").attr("disabled",false);
	}else{
		var number = $("#number").val();
		var ptName = $("#ptName").val();
		var ptStandard = $("#ptStandard").val();
		var testTime = $("#testTime").val();
		var tInsPerson = $("#piPerson").val();
		var tInsDate = $("#piDate").val();
		var tStation = "气密检测工位";
		var facilityNumber = $("#facilityNumber").val();
		var gIntervalTime = $("#gIntervalTime").val();
		var remark01 = $("#remark01").val();
		var remark02 = $("#remark02").val();
		var remark04 = $("#remark04").val();	
		if(facilityNumber==""){
			toastr.warning("请输入设备编号！");
			$("#firstBtn").attr("disabled",false);
		}else if(gResult==""){
			toastr.warning("请选择检验结果！");
			$("#firstBtn").attr("disabled",false);
		}else{
			$.ajax({
				type:'post'
				,url:'${pageContext.request.contextPath }/gas/insertGas.do'
				,data:{number:number,gCode:gCode,facilityNumber:facilityNumber,gIntervalTime:gIntervalTime,gResult:gResult,testTime:testTime}
				,dataType:'json'
				,success:function(res){
					if(res>0){
						/* if(gResult=="异常处理"){
							//异常判定推送到不合格处置
							$.ajax({
								type:'post'
								,url:'${pageContext.request.contextPath }/leakHunting/insertProductToTest.do'
								,data:{tNumber:number,tCode:gCode,tName:ptName,tStandard:ptStandard,tWay:gResult,tStatus:"0",tTestDate:testTime,tInsPerson:tInsPerson,tInsDate:tInsDate,tStation:tStation}
								,dataType:'json'
							})
						} */
						toastr.success("保存成功！");
						setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
							window.location.reload();  
						},2000);
					}else{
						toastr.error("保存失败！");
					}
				}
			})
		}
	}
}
//二次检测
function second(){
	$("#secondBtn").attr("disabled",true);
	save();
}
//气密判定
function gasOver(){
	$("#thirdBtn").attr("disabled",true);
	var gCode = $("#gCode").val();
	var gResult = $("#gResult").val();
	if(gCode==""){
		toastr.warning("请先扫描条形码！");
		$("#thirdBtn").attr("disabled",false);
	}else{
		var number = $("#number").val();
		var ptName = $("#ptName").val();
		var ptStandard = $("#ptStandard").val();
		var testTime = $("#testTime").val();
		var tInsPerson = $("#piPerson").val();
		var tInsDate = $("#piDate").val();
		var tStation = "气密检测工位";
		var facilityNumber = $("#facilityNumber").val();
		var gIntervalTime = $("#gIntervalTime").val();
		var remark01 = $("#remark01").val();
		var remark02 = $("#remark02").val();
		var remark04 = $("#remark04").val();
		var remark05 = "已判定";
		if(facilityNumber==""){
			toastr.warning("请输入设备编号！");
			$("#thirdBtn").attr("disabled",false);
		}else if(gResult==""){
			toastr.warning("请选择检验结果！");
			$("#thirdBtn").attr("disabled",false);
		}else{
			$.ajax({
				type:'post'
				,url:'${pageContext.request.contextPath }/gas/insertGas.do'
				,data:{number:number,gCode:gCode,facilityNumber:facilityNumber,gIntervalTime:gIntervalTime,gResult:gResult,testTime:testTime,remark05:remark05}
				,dataType:'json'
				,success:function(res){
					if(res>0){
						if(gResult=="异常处理"){
							//异常判定推送到不合格处置
							$.ajax({
								type:'post'
								,url:'${pageContext.request.contextPath }/leakHunting/insertProductToTest.do'
								,data:{tNumber:number,tCode:gCode,tName:ptName,tStandard:ptStandard,tWay:gResult,tStatus:"0",tTestDate:testTime,tInsPerson:tInsPerson,tInsDate:tInsDate,tStation:tStation}
								,dataType:'json'
							})
						}
						toastr.success("提交成功！");
						setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
							window.location.reload();  
						},2000);
						
					}else{
						toastr.error("提交失败！");
					}
				}
			})
		}
	}
}
//最终判定
function over(){
	var productCode = $("#gCode").val();
	if(productCode==""){
		toastr.warning("请先扫描条形码！");
	}else{
		$.ajax({
		   	 url:'${pageContext.request.contextPath }/numbered/selectProductTest.do'
					,type:'post'
					,data:{"code":productCode}
					,dataType:'json'
					,success:function(data){
						if(data == 0){
	 						toastr.warning("未找到订单！");
	 						setTimeout(function(){  //使用  setTimeout（）方法设定定时500毫秒
	 							window.location.reload();  
	 						},500);
	 					}else{
	 						$.ajax({
	 							url:'${pageContext.request.contextPath }/productTracing/selectGasInfoByCode.do'
	 							,type:'post'
	 							,data:{"productCode":productCode}
	 							,dataType:'json'
	 							,success:function(res){
	 								if(res.count>0){
	 									layer.open({
	 			 					        type: 1 					//Page层类型
	 			 					        ,area: ['95%', '750px']   //宽  高
	 			 					        ,title: '组件检测记录'
	 			 					        ,shade: 0.6 				//遮罩透明度
	 			 					        ,maxmin: true			    //允许全屏最小化
	 			 					        ,anim: 1 					//0-6的动画形式，-1不开启
	 			 					        /* ,content: $("#lookupTable2") */
	 			 					        ,content:   '<h2 style="text-align: center;color:#666">数点记录</h2>'+
	 			 					        			'<table class="layui-hide" id="numberedInfo" lay-filter="numberedInfo"></table>'+
	 			 					        			'<h2 style="text-align: center;color:#666">检漏记录</h2>'+
	 			 					        			'<table class="layui-hide" id="leakHuntingInfo" lay-filter="leakHuntingInfo"></table>'+
	 			 					        			'<h2 style="text-align: center;color:#666">组件评价记录</h2>'+
	 			 					        			'<table class="layui-hide" id="evaluateInfo" lay-filter="evaluateInfo"></table>'+
	 			 					        			'<h2 style="text-align: center;color:#666">气密性检测记录</h2>'+
	 			 					        			'<table class="layui-hide" id="gasInfo" lay-filter="gasInfo"></table>'+
	 			 					        			'<div style="margin:30px auto">'+
	 			 											'<label class="layui-form-label">最终结果：</label>'+
	 			 											'<select class="layui-select" style="width:300px" id="overResult">'+
	 			 								   				'<option value="合格">合格</option>'+
	 			 								   				'<option value="降级">降级</option>'+
	 			 								   				'<option value="异常处理">异常处理</option>'+
	 			 							   				'</select>'+
	 			 							   				'<div style="width:50px;display:inline-block"></div>'+
	 			 							   				'<input type="button" id="overBtn"  class="layui-btn" onclick="overSubmit()" value="提交"/>'+
	 			 						   				'</div>'
	 			 					        ,success:function(){
	 			 					            layui.use(['table'], function(){
	 			 					                var table = layui.table;
	 			 					                table.render({
	 			 					                    elem: '#numberedInfo'
	 			 					                    ,url:'${pageContext.request.contextPath }/leakHunting/selectNumberedInfoByCode.do?productCode='+productCode
	 			 					                    ,title: '数点记录'
	 			 					                    ,limits:[10,20,30]
	 			 					                   ,cols: [[
	 			 					             			  {field:'', title:'序号', sort: true, type:'numbers', width: 60}
	 			 					             			  ,{field:'rjNumA', title:'A面软胶堵漏数', width: 90}
	 			 					             		      ,{field:'rjNumB', title:'B面软胶堵漏数', width: 90}
	 			 					             		      ,{field:'yjNumA', title:'A面硬胶堵漏数', width: 90}
	 			 					             		      ,{field:'yjNumB', title:'B面硬胶堵漏数', width: 90}
	 			 					             		      ,{field:'ryjNumCountA', title:'A面软硬胶堵漏总数', width: 100}
	 			 					             		      ,{field:'ryjNumCountB', title:'B面软硬胶堵漏总数', width: 100}
	 			 					             		      ,{field:'bsNumA', title:'A面瘪丝数', width: 90}
	 			 					             		      ,{field:'bsNumB', title:'B面瘪丝数', width: 90}
	 			 					             		      ,{field:'wqysNumA', title:'A面弯曲压丝数', width: 90}
	 			 					             		      ,{field:'wqysNumB', title:'B面弯曲压丝数', width: 90}
	 			 					             		      ,{field:'isNormal', title:'端面是否正常', width: 90}
	 			 					             		      ,{field:'place', title:'异常位置', width: 90}
	 			 					             		      ,{field:'describe', title:'非正常描述', width: 130}
	 			 					             		      ,{field:'testPerson', title:'数点人', width: 90}
	 			 					             		      ,{field:'testTime',width:160, title:'数点日期',templet:function (row){
	 			 					                         		return date2String(row.testTime);
	 			 					                     		}
	 			 					             		      }
	 			 					             		    ]]
	 			 					          	    	,page: true
	 			 					                });
	 			 					                table.render({
	 			 					                    elem: '#leakHuntingInfo'
	 			 					                    ,url:'${pageContext.request.contextPath }/productTracing/selectLeakHuntingInfoByCode.do?productCode='+productCode
	 			 					                    ,title: '检漏记录'
	 			 					                    ,limits:[10,20,30]
	 			 						                ,cols: [[
	 			 						          			   {field:'', title:'序号', sort: true, type:'numbers', width: 60}
	 			 						          			  ,{field:'leakHunting',width:100, title: '检漏序列',templet:'#leakHuntingList',totalRowText: '合计'}
	 			 						          		      ,{field:'facilityNumber', title:'设备编号', width: 80}
	 			 						          		      ,{field:'aDlNumBig', title:'A面堵漏个数大', width: 80}
	 			 						          		      ,{field:'aDlNumSmall', title:'A面堵漏个数小', width: 80}
	 			 						          		      ,{field:'bDlNumBig', title:'B面堵漏个数大', width: 80}
	 			 						          		      ,{field:'bDlNumSmall', title:'B面堵漏个数小'}
	 			 						          		      ,{field:'aCount', title:'A面总数',totalRow: true}
	 			 						          		      ,{field:'bCount', title:'B面总数',totalRow: true}
	 			 						          		      ,{field:'isNormal', title:'检漏是否正常'}
	 			 						          		      ,{field:'lhResult', title:'检漏结果'}
	 			 						          		      ,{field:'describe', title:'非正常描述'}
	 			 						          		      ,{field:'testTime',width:160, title:'日期',templet:function (row){
	 			 						                      		return date2String(row.testTime);
	 			 						                  		}
	 			 						          		      }
	 			 						          		    ]]
	 			 					          	    	,page: true
	 			 					                });
	 			 					                table.render({
	 			 					            	    elem: '#evaluateInfo'
	 			 					            	    ,url:'${pageContext.request.contextPath }/productTracing/selectEvaluateInfoByCode.do?productCode='+productCode
	 			 					            	    ,title: '组件评价'
	 			 					            	    ,cols: [[
	 			 					            	      {field:'', title:'序号', sort: true, type:'numbers', width: 60}
	 			 					            	      ,{field:'yxsw', title:'运行水温℃',width: 160}
	 			 					            	      ,{field:'jsyl', title:'进水压力MPa',width: 160}
	 			 					            	      ,{field:'csyl', title:'产水压力MPa',width: 160}
	 			 					            	      ,{field:'nsyl', title:'浓水压力MPa',width: 160}
	 			 					            	      ,{field:'cstl', title:'产水通量T/h',width: 160}
	 			 					            	      ,{field:'nstl', title:'浓水通量T/h',width: 160}
	 			 					            	      ,{field:'yxTime', title:'运行时间h',width: 160}
	 			 					            	      ,{field:'evResult', title:'检测结果',width: 200}
	 			 					            	      ,{field:'testTime',width:160, title:'日期',templet:function (row){
	 			 					                      		return date2String(row.testTime);
	 			 					                  		}
	 			 					            	      }
	 			 					            	    ]]
	 			 					            	    ,page: false
	 			 					            	});
	 			 					                table.render({
	 			 					            	    elem: '#gasInfo'
	 			 					            	    ,url:'${pageContext.request.contextPath }/productTracing/selectGasInfoByCode.do?productCode='+productCode
	 			 					            	    ,title: '气密检测'
	 			 					            	    ,limits:[10,20,30]
	 			 					            	    ,cols: [[
	 			 					            	      {field:'', title:'序号', sort: true, type:'numbers', width: 60}
	 			 					            	      ,{field:'gas', width:150, title: '气密性检测序列',templet:'#gasList'}
	 			 					            	      ,{field:'gIntervalTime', title:'出泡间隔时间s',width:600}
	 			 					            	      ,{field:'gResult', title:'检测结果',width: 400}
	 			 					            	      ,{field:'testTime',width:330, title:'日期',templet:function (row){
	 			 					                      		return date2String(row.testTime);
	 			 					                  		}
	 			 					            	      }
	 			 					            	    ]]
	 			 					            	    ,page: true
	 			 					            	});
	 			 					            });
	 			 					        }
	 			 						})
	 								}else{
	 									toastr.warning("请先进行气密检测！");
	 								}
	 							}
	 						})
	 					}
					}
			})
	}
}
//最终判定
function overSubmit(){
	$("#overBtn").attr("disabled",true);
	var number = $("#number").val();
	var gCode = $("#gCode").val();
	var ptName = $("#ptName").val();
	var ptStandard = $("#ptStandard").val();
	var overResult = $("#overResult").val();
	var testTime = $("#testTime").val();
	var tInsPerson = $("#piPerson").val();
	var tInsDate = $("#piDate").val();
	var tStation = "气密性检测工位";
	var remark01 = $("#remark01").val();
	var remark02 = $("#remark02").val();
	var remark04 = $("#remark04").val();
	
	
	var type=0;
	if(overResult=="异常处理"){
		//异常判定推送到不合格处置
		$.ajax({
			type:'post'
			,url:'${pageContext.request.contextPath }/leakHunting/insertProductToTest.do'
			,data:{tNumber:number,tCode:gCode,tName:ptName,tStandard:ptStandard,tWay:overResult,tStatus:"0",tTestDate:testTime,tInsPerson:tInsPerson,tInsDate:tInsDate,tStation:tStation}
			,dataType:'json'
			,success:function(res){
				if(res!=0){
					toastr.success("提交成功！");
					setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
						window.location.reload();  
					},2000);
				}else{
					toastr.error("提交失败！");
				}
			}
		})
	}else{
		//合格降级减库存
		if(overResult=="合格" || overResult=="降级"){
			if(overResult=="合格"){
				type=1;
			}else if(overResult=="降级"){
				type=4;
			}
			//减库存
			$.ajax({
				type:'post'
				,url:'${pageContext.request.contextPath }/lineSideLibrary/lineSideLibraryOut.do?pnum='+remark01+'&&quantity=1&&productionOrder='+remark02+'&&team='+remark04+'&&type='+type+'&&positionName=包装'
				,dataType:'json'
				,success:function(res){
					
				}
			})
		}
		//合格降级修改订单状态
		$.ajax({
			type:'post'
			,url:'${pageContext.request.contextPath }/leakHunting/updateProductStatus.do'
			,data:{tNumber:number,remark03:overResult}
			,dataType:'json'
			,success:function(res){
				if(res!=0){
					toastr.success("提交成功！");
					setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
						window.location.reload();  
					},2000);
				}else{
					toastr.error("提交失败！");
				}
			}
		})
	}
	
}
	toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
	</script>
</body>
</html>